import { computed } from 'vue'
import { mapGetters, useStore } from 'vuex'
 
export function useGetters(mapper) {
  // 拿到store独享
  const store = useStore()
 
  const StateFns = mapGetters(mapper)
 
  // 对数据进行转换
  const storeState = {}
  Object.keys(StateFns).forEach(Key => {
    const fn = StateFns[Key].bind({$store: store})
    storeState[Key] = computed(fn)
  })
 
  return storeState
}